<!--
 * @Author: Wangtao
 * @Date: 2019-08-27 16:45:02
 * @LastEditors: Wangtao
 * @LastEditTime: 2020-10-09 14:32:14
-->
<template>
  <div class="export_call">
    <el-tabs v-model="activeName" @tab-click="handleClick">
      <el-tab-pane v-for="(item,index) in menu" :key="index" :label="item.value" :name="item.name"></el-tab-pane>
    </el-tabs>
    <keep-alive>
      <component :is="activeName"></component>
    </keep-alive>
  </div>
</template>
<script>
  import CallRecordExport from './CallRecordExport.vue'
  import RecordingTaskExport from './RecordingTaskExport.vue'
  import ChatContentExport from './ChatContentExport.vue'
  import LeakSheetExport from './LeakSheetExport.vue'
  import {isHasMenu, isHasFunc} from '@/utils/m7Utils.js'
  export default {
    data () {
      return {
        activeName: 'CallRecordExport',
        menu: [
          {name: 'CallRecordExport', value: this.$t('call.AudioExportTask')},
          {name: 'RecordingTaskExport', value: this.$t('call.CallRecordExportTask')},
          {name: 'ChatContentExport', value: this.$t('call.ChatContentExport')}
        ]
      }
    },
    methods: {
      handleClick (tab) {
        console.log(tab)
      }
    },
    components: {
      CallRecordExport,
      RecordingTaskExport,
      ChatContentExport,
      LeakSheetExport
    },
    beforeMount () {
      let isRecord = isHasMenu('batch_export_record_task', this.$store.state.session.user)
      let isLeakSheet = isHasMenu('assign_missed_cdr_export_task', this.$store.state.session.user)
      let isCdr = isHasMenu('batch_export_cdr_task', this.$store.state.session.user)
      let isChat = isHasMenu('download_chat_content_task', this.$store.state.session.user)
      let menu = []
      if (isLeakSheet) {
        menu.unshift({name: 'leakSheetExport', value: this.$t('call.callLeakTask')})
      }
      if (isChat) {
        menu.unshift({name: 'ChatContentExport', value: this.$t('call.ChatContentExport')})
      }
      if (isCdr) {
        menu.unshift({name: 'RecordingTaskExport', value: this.$t('call.CallRecordExportTask')})
      }
      if (isRecord) {
        menu.unshift({name: 'CallRecordExport', value: this.$t('call.AudioExportTask')})
      }
      this.activeName = menu[0].name
      this.menu = menu
    }
  }
</script>
<style lang="stylus" rel="stylesheet/stylus" scoped>
  @import "../../../assets/common.styl"
  .export_call
    height calc(100vh - 52px)
    overflow-y auto
    background-color $cf-white

</style>
